Various fixes to make quiche healthy for migration. * Replace src/ffi.rs with version in crate archive. env!("CARGO_PKG_VERSION") is now handled correctly. * Add ffi_headers.bp.fragment with the FFI headers in include/ * Update Android.bp.patch to also patch the license section with all applicable licenses. Bug: http://b/339424309 Test: treehugger Change-Id: I1b455d7feef7c12be3d6284486db6cc02103da81 
diff --git a/Android.bp b/Android.bp index 1b4784b..aa8090e 100644 --- a/Android.bp +++ b/Android.bp 
@@ -1,48 +1,20 @@  // This file is generated by cargo_embargo. -// Do not modify this file after the first "rust_*" or "genrule" module -// because the changes will be overridden on upgrade. -// Content before the first "rust_*" or "genrule" module is preserved. +// Do not modify this file because the changes will be overridden on upgrade.    package {  default_applicable_licenses: ["external_rust_crates_quiche_license"], + default_team: "trendy_team_android_rust",  }   -// Added automatically by a large-scale-change that took the approach of -// 'apply every license found to every target'. While this makes sure we respect -// every license restriction, it may not be entirely correct. -// -// e.g. GPL in an MIT project might only apply to the contrib/ directory. -// -// Please consider splitting the single license below into multiple licenses, -// taking care not to lose any license_kind information, and overriding the -// default license using the 'licenses: [...]' property on targets as needed. -// -// For unused files, consider creating a 'fileGroup' with "//visibility:private" -// to attach the license to, and including a comment whether the files may be -// used in the current project. -// See: http://go/android-license-faq  license {  name: "external_rust_crates_quiche_license",  visibility: [":__subpackages__"],  license_kinds: [ - "SPDX-license-identifier-BSD", + "SPDX-license-identifier-BSD-2-Clause",  "SPDX-license-identifier-ISC",  "SPDX-license-identifier-OpenSSL", - "legacy_unencumbered",  ], - license_text: [ - "COPYING", - ], -} - -cc_library_headers { - name: "libquiche_ffi_headers", - export_include_dirs: ["include"], - apex_available: [ - "//apex_available:platform", - "com.android.resolv", - ], - min_sdk_version: "29", + license_text: ["LICENSE"],  }    rust_library { @@ -217,3 +189,13 @@  vendor_available: true,  min_sdk_version: "29",  } + +cc_library_headers { + name: "libquiche_ffi_headers", + export_include_dirs: ["include"], + apex_available: [ + "//apex_available:platform", + "com.android.resolv", + ], + min_sdk_version: "29", +} 
diff --git a/cargo_embargo.json b/cargo_embargo.json index e589563..4c2297c 100644 --- a/cargo_embargo.json +++ b/cargo_embargo.json 
@@ -7,6 +7,7 @@  "package": {  "quiche": {  "patch": "patches/Android.bp.patch", + "add_toplevel_block": "ffi_headers.bp.fragment",  "test_data": {  "src/lib.rs": [  "examples/cert.crt", 
diff --git a/ffi_headers.bp.fragment b/ffi_headers.bp.fragment new file mode 100644 index 0000000..25ef953 --- /dev/null +++ b/ffi_headers.bp.fragment 
@@ -0,0 +1,9 @@ +cc_library_headers { + name: "libquiche_ffi_headers", + export_include_dirs: ["include"], + apex_available: [ + "//apex_available:platform", + "com.android.resolv", + ], + min_sdk_version: "29", +} 
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch index 4beeec7..9b434ab 100644 --- a/patches/Android.bp.patch +++ b/patches/Android.bp.patch 
@@ -2,6 +2,19 @@  index a1a223b..1b4784b 100644  --- a/Android.bp  +++ b/Android.bp +@@ -9,7 +9,11 @@ package { + license { + name: "external_rust_crates_quiche_license", + visibility: [":__subpackages__"], +- license_kinds: ["SPDX-license-identifier-BSD-2-Clause"], ++ license_kinds: [ ++ "SPDX-license-identifier-BSD-2-Clause", ++ "SPDX-license-identifier-ISC", ++ "SPDX-license-identifier-OpenSSL", ++ ], + license_text: ["LICENSE"], + } +  @@ -46,70 +46,64 @@ cc_library_headers {  }   
diff --git a/src/ffi.rs b/src/ffi.rs index 38e82c4..36cb40d 100644 --- a/src/ffi.rs +++ b/src/ffi.rs 
@@ -102,10 +102,7 @@    #[no_mangle]  pub extern fn quiche_version() -> *const u8 { - //static VERSION: &str = concat!("0.17.1", "\0"); - // ANDROID's build system doesn't support environment variables - // so we hardcode the package version here. - static VERSION: &str = concat!("0.6.0", "\0"); + static VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "\0");  VERSION.as_ptr()  }